﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-03-03
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web.Configuration;


namespace SRF.Security.Permission
{
    public class PermissionFactory
    {
        public static PermissionProvider Provider
        {
            get
            {
                PermissionProvider provider = null;
                PermissionSection section = (PermissionSection)ConfigurationManager.GetSection("PermissionProvider");
                if (section != null)
                {
                    PermissionProviderCollection _providers = new PermissionProviderCollection();
                    ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(PermissionProvider));
                    if (!string.IsNullOrEmpty(section.DefaultProvider))
                    {
                        provider = _providers[section.DefaultProvider];
                    }
                }
                if (provider == null)
                    provider = new PermissionProvider();

                return provider;
            }
        }
    }
}